package com.tmt.im.jpa.entity;

import com.tmt.data.jpa.entity.TmtBaseEntityId;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;

import java.io.Serial;
import java.io.Serializable;

/**
 * 好友记录表
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/24 15:09
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "im_friend", description = "好友表")
@Entity
@Table(name = "im_friend")
public class IMFriend extends TmtBaseEntityId implements Serializable {

    @Serial
    private static final long serialVersionUID = -6510387844939763081L;

    /**
     * owner设置的好友的备注
     */
    private String alias;

    /**
     * 免打扰状态
     */
    private boolean noDisturbing = false;

    /**
     * friend用户发送的信息是否在owner用户对话列表中置顶。
     */
    private boolean holdInTop = false;

    /**
     * 是否在黑名单中
     */
    private boolean inBlackBill = false;

    /**
     * 好友对象
     */
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    private IMUser friend;

    /**
     * 本条好友记录的拥有者。
     */
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY, optional = false)
    private IMUser owner;

    /**
     * 关联的好友申请记录
     */
    @ManyToOne(cascade = {CascadeType.REFRESH}, fetch = FetchType.LAZY)
    private IMFriendApply friendApply;

}
